﻿using NUnit.Framework;
using Pantry.DataAccess;
using Pantry.Entity;

namespace Pantry.UnitTest
{
    [TestFixture]
    class TestServiceDao
    {
        private const string ConnectionString = "Server=10.16.102.126;Database=Pantry_MockProject;Integrated Security=True;";
        private readonly ServiceDao _serviceDao;
        private readonly FunderDao _funderDao;

        public TestServiceDao()
        {
            _serviceDao = new ServiceDao(ConnectionString);
            _funderDao = new FunderDao(ConnectionString);
        }

        /// <summary>
        /// Test inserts the service.
        /// </summary>
        [Test, Sequential]
        public void InsertService()
        {
            var service = new Service
                              {
                                  Name =  "CallVideo",
                                  ShortDescription = "ShortDescription",
                                  ServiceType = "ServiceType",
                                  ContactId = 2,
                                  IsActive = 1,
                                  ServiceSubType = "ServiceSubType",
                                  FullDescription = "FullDescription",
                                  DeptCode = "DeptCode",
                                  ClientDescription = "ClientDescription",
                                  DescriptionDelivery = "DescriptionDelivery",
                                  ServiceAttendace = "ServiceAttendace",
                                  ServiceStartExpected = "1/1/2012",
                                  ServiceStart = "2/2/2012",
                                  ServiceEnd = "3/3/2012",
                                  ServiceExtendable = true,
                                  ServiceContractCode = "ServiceContractCode",
                                  ServiceContractValue = "ServiceContractValue",
                                  ContractStagedPayment = false,
                                  ReferralProcessMethod = "ReferralProcessMethod",
                                  ServiceTimeLimited = true,
                                  ServiceTimeLimitedMonth = 5,
                                  ServiceExtendableMonth = 5,
                                  SerBenCrit = "SerBenCrit",
                                  SerBarCrit = "SerBarCrit",
                                  SerEthCrit = "SerEthCrit",
                                  SerDisCrit = "SerDisCrit",
                                  SerPerCirCrit = "SerPerCirCrit",
                                  SerOrtherCrit = "SerOrtherCrit",
                                  ClientSupportProcess = "ClientSupportProcess",
                                  ClientOutcome = "ClientOutcome",
                                  Intervention = "Intervention",
                                  TargetClient = "TargetClient",
                                  ClientJourney = "ClientJourney",
                                  Accreditation = "Accreditation",
                                  OtherService = "OtherService",
                                  ReferralSources = "ReferralSources",
                                  ProgrammeId = 2,
                                  SupportCenters = "SupportCenters",
                                  ContractOutcome = "ContractOutcome",
                                  Participartion = "Participartion",
                                  ContractObligation = "ContractObligation"
                              };
            int result = _serviceDao.InsertService(service);
            const int expectedResult = 1; // insert successful
            Assert.AreEqual(expectedResult, result, "Test Successful");
        }

        /// <summary>
        /// Test inserts the funding.
        /// </summary>
        [Test, Sequential]
        public void InsertFunding()
        {
            var funder = new Funder
                             {
                                 FundingSource = "FundingSource",
                                 ContactId = 2,
                                 FundingAmount = (float)5.5,
                                 FundingNeeds = "FundingNeeds",
                                 FundingContinuationNeed = true,
                                 FundingStart = "1/1/2012",
                                 FundingEnd = "2/2/2012",
                                 FundingCotinuationAmount = (float)100,
                                 FundingContinuationDetail = "FundingContinuationDetail",
                                 FundrasingForText = "FundrasingForText",
                                 FundrasingNeeds = "FundrasingNeeds",
                                 FundrasingWhy = "FundrasingWhy",
                                 FundrasingComplete = true,
                                 FundrasingRequireBy = "5/3/2010",
                                 FundrasingDonorAnonymous = false,
                                 FundrasingDonorAmount = "20",
                                 FundrasingDonationDate = "2/1/2010",
                                 FundrasingDonationIncremental = false,
                                 FundrasingCompleteDate = "6/15/1990",
                                 ServiceId = 2
                             };
            int result = _funderDao.InsertFunder(funder);
            const int expectedResult = 1; // insert successful
            Assert.AreEqual(expectedResult, result, "Test successful");
        }
    }
}
